package cubelabs.nexus.dao;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import cubelabs.nexus.entity.Availability;

@Repository("avaliabilityDAO")
public class AvailabilityDAO extends BaseDAO<Availability, Long> {

    public Availability findByUser(long userId) {
        Availability availability = null;
        List<Availability> avlist = findByCriteria(Restrictions.eq("user.id", userId));
        if (avlist != null && avlist.isEmpty()) {
            availability = avlist.get(0);
        }
        return availability;
    }
}
